﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BestCode.Creds.Business;
using BestCode.Creds.Entities;
using BestCode.Wpf.ViewModel;
using BestCode.Wpf.ViewModel.Commanding.Contracts;
using BestCode.Wpf.ViewModel.Data;

namespace BestCode.Creds.UI.ViewModel
{
    public class VmTemplate : DataModelBase<Template>
    {
        private TemplateBusiness negocios = new TemplateBusiness();


        public ICommandEvent CmdBrowse { get; set; }
        public ICommandEvent CmdSetLayout { get; set; }
        

        public VmTemplate()
        {
            
            SetDataService(negocios);
            GetAll();

            CmdBrowse = new DelegateCommand<string>(ExecuteCmdBrowse, CanExecuteCmdBrowse);
        }

        public void ExecuteCmdBrowse(string param)
        {
            //var fbd = new System.Windows.Forms.FolderBrowserDialog();
            //fbd.SelectedPath = string.IsNullOrEmpty(SelectedItem.FaceImagePath)?"C:\\":SelectedItem.FaceImagePath;
            //var result = fbd.ShowDialog();

            //if (result.ToString().Equals("OK"))
            //    SelectedItem.FaceImagePath = fbd.SelectedPath;

            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            

            openFileDialog1.InitialDirectory = "c:\\" ;
            openFileDialog1.Filter = "Images files (*.png)|*.png|All files (*.*)|*.*" ;
            openFileDialog1.FilterIndex = 2 ;
            openFileDialog1.RestoreDirectory = true ;
            
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                SelectedItem.FaceImagePath = openFileDialog1.FileName;
            }
        }

        public bool CanExecuteCmdBrowse(string param)
        {
            return true;
        }
    }
}
